<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>Untitled Document</title>
		<script type=text/javascript charset=utf-8>
			
			//call apply  简单的用法:绑定一些函数 用于传递参数 调用 
			
			/*
			function sum(x , y){
				return x+y;
			}
			function call1(num1 , num2){
				return sum.call(this , num1 , num2);
			}
			function apply1(num1 , num2){
				return sum.apply(this , [num1,num2]);
			}
			alert(call1(10 , 20));
			alert(apply1(20,40));
			*/
			
			//扩充作用域
			
			/*
			window.color = 'red';
			var obj = {color:'blue'};
			var obj2 = {color:'yellow'};
			function showColor(){
				alert(this.color);
			}
			
			//showColor.call(window);
			//showColor.call(obj);
			*/
			
			
			
			// call方法的简单模拟与实现
			
			//function 方法
			function test1(a , b){
				return a+b;
			}
			
			// 自定义的对象
			function Obj(x, y){
				this.x = x ; 
				this.y = y ;
				return x*y;
			}
			
			var o = new Obj(10 , 20);
			o.method = test1 ;
			alert(o.method(o.x , o.y));
			delete o.method;
			
			//alert(test1.call(o,o.x ,o.y));
			
			
			
			
			
			
		</script>
	</head>
	<body>
	</body>
</html>
